// $ANTLR 3.4 C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g 2012-11-19 18:01:28

package PL.prac9;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked"})
public class XMLParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "AUTOR", "BARRA", "BIBLIOTECA", "BLANCO", "CADENA", "COMENTARIO", "COMILLAS", "DIGITO", "EDITORIAL", "END_AUTOR", "END_BIBLIOTECA", "END_EDITORIAL", "END_LIBRO", "END_TITULO", "EXCLAMACION", "GUIONES", "IGUAL", "LETRA", "LIBRO", "MAYOR", "MENOR", "NUMERO", "PALABRA", "TITULO"
    };

    public static final int EOF=-1;
    public static final int AUTOR=4;
    public static final int BARRA=5;
    public static final int BIBLIOTECA=6;
    public static final int BLANCO=7;
    public static final int CADENA=8;
    public static final int COMENTARIO=9;
    public static final int COMILLAS=10;
    public static final int DIGITO=11;
    public static final int EDITORIAL=12;
    public static final int END_AUTOR=13;
    public static final int END_BIBLIOTECA=14;
    public static final int END_EDITORIAL=15;
    public static final int END_LIBRO=16;
    public static final int END_TITULO=17;
    public static final int EXCLAMACION=18;
    public static final int GUIONES=19;
    public static final int IGUAL=20;
    public static final int LETRA=21;
    public static final int LIBRO=22;
    public static final int MAYOR=23;
    public static final int MENOR=24;
    public static final int NUMERO=25;
    public static final int PALABRA=26;
    public static final int TITULO=27;

    // delegates
    public Parser[] getDelegates() {
        return new Parser[] {};
    }

    // delegators


    public XMLParser(TokenStream input) {
        this(input, new RecognizerSharedState());
    }
    public XMLParser(TokenStream input, RecognizerSharedState state) {
        super(input, state);
    }

    public String[] getTokenNames() { return XMLParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g"; }


      // Al faltar un token, intenta una recuperación de errores llamando a esta función, por lo tanto no lanzaba la excepción y sólo mostraba el error indicándolo.
      // Sobreescribimos la función para que lance de nuevo la excepción y poder capturarla por nuestra cuenta.
      protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException {
          throw new MismatchedTokenException(ttype, input);
      }
      //Variable que controlará si la regla se encuentra o no antes de un end de etiqueta.
      boolean in;
      int numerrores = 0;
      public int errores () {
        return numerrores;
        }



    // $ANTLR start "entrada"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:27:1: entrada : biblioteca EOF ;
    public final void entrada() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:27:9: ( biblioteca EOF )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:27:11: biblioteca EOF
            {
            pushFollow(FOLLOW_biblioteca_in_entrada49);
            biblioteca();

            state._fsp--;


            match(input,EOF,FOLLOW_EOF_in_entrada51); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "entrada"



    // $ANTLR start "biblioteca"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:31:1: biblioteca : BIBLIOTECA ( libro )+ END_BIBLIOTECA ;
    public final void biblioteca() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:31:12: ( BIBLIOTECA ( libro )+ END_BIBLIOTECA )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:31:14: BIBLIOTECA ( libro )+ END_BIBLIOTECA
            {
            match(input,BIBLIOTECA,FOLLOW_BIBLIOTECA_in_biblioteca61); 

            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:31:25: ( libro )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==LIBRO) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:31:25: libro
            	    {
            	    pushFollow(FOLLOW_libro_in_biblioteca63);
            	    libro();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);


            in = true;

            match(input,END_BIBLIOTECA,FOLLOW_END_BIBLIOTECA_in_biblioteca68); 

            in = false;

            }

        }
        catch (RecognitionException ex) {
            Token t = input.LT(1);
                                                                                     if (in) System.out.println("falta cierre de biblioteca.");
                                                                                     numerrores++;
                                                                                     
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "biblioteca"



    // $ANTLR start "libro"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:38:1: libro : LIBRO cuerpo_libro END_LIBRO ;
    public final void libro() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:38:6: ( LIBRO cuerpo_libro END_LIBRO )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:38:8: LIBRO cuerpo_libro END_LIBRO
            {
            match(input,LIBRO,FOLLOW_LIBRO_in_libro231); 

            pushFollow(FOLLOW_cuerpo_libro_in_libro233);
            cuerpo_libro();

            state._fsp--;


            in = true;

            match(input,END_LIBRO,FOLLOW_END_LIBRO_in_libro237); 

            in = false;

            }

        }
        catch (RecognitionException ex) {
            Token t = input.LT(1);
                                                                                     if (in) System.out.println("falta cierre de libro.");
                                                                                     numerrores++;
                                                                                     
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "libro"



    // $ANTLR start "cuerpo_libro"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:45:1: cuerpo_libro : titulo autor ( editorial )? ;
    public final void cuerpo_libro() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:45:13: ( titulo autor ( editorial )? )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:45:15: titulo autor ( editorial )?
            {
            pushFollow(FOLLOW_titulo_in_cuerpo_libro399);
            titulo();

            state._fsp--;


            pushFollow(FOLLOW_autor_in_cuerpo_libro401);
            autor();

            state._fsp--;


            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:45:28: ( editorial )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==EDITORIAL) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:45:29: editorial
                    {
                    pushFollow(FOLLOW_editorial_in_cuerpo_libro404);
                    editorial();

                    state._fsp--;


                    }
                    break;

            }


            }

        }
        catch (RecognitionException ex) {
            numerrores++;throw ex;
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "cuerpo_libro"



    // $ANTLR start "titulo"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:48:1: titulo : TITULO linea END_TITULO ;
    public final void titulo() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:48:7: ( TITULO linea END_TITULO )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:48:9: TITULO linea END_TITULO
            {
            match(input,TITULO,FOLLOW_TITULO_in_titulo420); 

            pushFollow(FOLLOW_linea_in_titulo422);
            linea();

            state._fsp--;


            in = true;

            match(input,END_TITULO,FOLLOW_END_TITULO_in_titulo426); 

            in = false;

            }

        }
        catch (RecognitionException ex) {

                                                                              Token t = input.LT(1);
                                                                              if (in) System.out.println("falta cierre de título.");
                                                                              numerrores++;
                                                                       
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "titulo"



    // $ANTLR start "autor"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:56:1: autor : AUTOR linea END_AUTOR ;
    public final void autor() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:56:6: ( AUTOR linea END_AUTOR )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:56:8: AUTOR linea END_AUTOR
            {
            match(input,AUTOR,FOLLOW_AUTOR_in_autor501); 

            pushFollow(FOLLOW_linea_in_autor503);
            linea();

            state._fsp--;


            in = true;

            match(input,END_AUTOR,FOLLOW_END_AUTOR_in_autor507); 

            in = false;

            }

        }
        catch (RecognitionException ex) {

                                                                     Token t= input.LT(1);
                                                                     numerrores++;
                                                                     if (in)  System.out.println("falta cierre de autor.");
                                                                     else if ((t.getText().equals("<editorial>")) || (t.getText().equals("</libro>"))){                                
                                                                       System.out.println ("Error, debe haber un autor.");
                                                                       consumeUntil(input, END_EDITORIAL);
                                                                       input.consume();
                                                                     }
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "autor"



    // $ANTLR start "editorial"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:67:1: editorial : EDITORIAL linea END_EDITORIAL ;
    public final void editorial() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:67:10: ( EDITORIAL linea END_EDITORIAL )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:67:12: EDITORIAL linea END_EDITORIAL
            {
            match(input,EDITORIAL,FOLLOW_EDITORIAL_in_editorial556); 

            pushFollow(FOLLOW_linea_in_editorial558);
            linea();

            state._fsp--;


            in = true;

            match(input,END_EDITORIAL,FOLLOW_END_EDITORIAL_in_editorial562); 

            in = false;

            }

        }
        catch (RecognitionException ex) {

                                                                                    Token t = input.LT(1);
                                                                                    numerrores++;
                                                                                     if (in) System.out.println("falta cierre de editorial.");
                                                                                  
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "editorial"



    // $ANTLR start "linea"
    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:73:1: linea : ( PALABRA )+ ;
    public final void linea() throws RecognitionException {
        try {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:73:6: ( ( PALABRA )+ )
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:73:8: ( PALABRA )+
            {
            // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:73:8: ( PALABRA )+
            int cnt3=0;
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==PALABRA) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // C:\\Users\\Jose\\workspace\\prac9\\src\\main\\java\\PL\\prac9\\XMLParser.g:73:8: PALABRA
            	    {
            	    match(input,PALABRA,FOLLOW_PALABRA_in_linea577); 

            	    }
            	    break;

            	default :
            	    if ( cnt3 >= 1 ) break loop3;
                        EarlyExitException eee =
                            new EarlyExitException(3, input);
                        throw eee;
                }
                cnt3++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "linea"

    // Delegated rules


 

    public static final BitSet FOLLOW_biblioteca_in_entrada49 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_entrada51 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_BIBLIOTECA_in_biblioteca61 = new BitSet(new long[]{0x0000000000400000L});
    public static final BitSet FOLLOW_libro_in_biblioteca63 = new BitSet(new long[]{0x0000000000404000L});
    public static final BitSet FOLLOW_END_BIBLIOTECA_in_biblioteca68 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LIBRO_in_libro231 = new BitSet(new long[]{0x0000000008000000L});
    public static final BitSet FOLLOW_cuerpo_libro_in_libro233 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_END_LIBRO_in_libro237 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_titulo_in_cuerpo_libro399 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_autor_in_cuerpo_libro401 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_editorial_in_cuerpo_libro404 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_TITULO_in_titulo420 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_linea_in_titulo422 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_END_TITULO_in_titulo426 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_AUTOR_in_autor501 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_linea_in_autor503 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_END_AUTOR_in_autor507 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_EDITORIAL_in_editorial556 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_linea_in_editorial558 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_END_EDITORIAL_in_editorial562 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_PALABRA_in_linea577 = new BitSet(new long[]{0x0000000004000002L});

}